package com.ruoyi.extensionmonitor.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.extensionmonitor.domain.InfoExtensionMonitorTarget;
import com.ruoyi.extensionmonitor.service.IInfoExtensionMonitorTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 延伸监控指标Controller
 * 
 * @author ruoyi
 * @date 2022-12-05
 */
@RestController
@RequestMapping("/extensionmonitor/extensionmonitortarget")
public class InfoExtensionMonitorTargetController extends BaseController
{
    @Autowired
    private IInfoExtensionMonitorTargetService infoExtensionMonitorTargetService;

    /**
     * 查询延伸监控指标列表
     */
    @GetMapping("/list")
    public TableDataInfo list(InfoExtensionMonitorTarget infoExtensionMonitorTarget)
    {
        startPage();
        List<InfoExtensionMonitorTarget> list = infoExtensionMonitorTargetService.selectInfoExtensionMonitorTargetList(infoExtensionMonitorTarget);
        return getDataTable(list);
    }

    /**
     * 导出延伸监控指标列表
     */
    @Log(title = "延伸监控指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoExtensionMonitorTarget infoExtensionMonitorTarget)
    {
        List<InfoExtensionMonitorTarget> list = infoExtensionMonitorTargetService.selectInfoExtensionMonitorTargetList(infoExtensionMonitorTarget);
        ExcelUtil<InfoExtensionMonitorTarget> util = new ExcelUtil<InfoExtensionMonitorTarget>(InfoExtensionMonitorTarget.class);
        util.exportExcel(response, list, "延伸监控指标数据");
    }

    /**
     * 获取延伸监控指标详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoExtensionMonitorTargetService.selectInfoExtensionMonitorTargetById(id));
    }

    /**
     * 新增延伸监控指标
     */
    @Log(title = "延伸监控指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoExtensionMonitorTarget infoExtensionMonitorTarget)
    {
        return toAjax(infoExtensionMonitorTargetService.insertInfoExtensionMonitorTarget(infoExtensionMonitorTarget));
    }

    /**
     * 修改延伸监控指标
     */
    @Log(title = "延伸监控指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoExtensionMonitorTarget infoExtensionMonitorTarget)
    {
        return toAjax(infoExtensionMonitorTargetService.updateInfoExtensionMonitorTarget(infoExtensionMonitorTarget));
    }

    /**
     * 删除延伸监控指标
     */
    @Log(title = "延伸监控指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoExtensionMonitorTargetService.deleteInfoExtensionMonitorTargetByIds(ids));
    }

    @DeleteMapping("/removeById/{id}")
    public AjaxResult removeById(@PathVariable Long id){
        return toAjax(infoExtensionMonitorTargetService.deleteInfoExtensionMonitorTargetById(id));
    }
}
